package com.cow.service.impl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.cow.mapper.FriendMapper;
import com.cow.mapper.UserMapper;
import com.cow.pojo.Friend;
import com.cow.pojo.FriendExample;
import com.cow.pojo.User;
import com.cow.service.FriendService;

/**
 * @author 光环and鬼泣
 * @version 2018年5月25日 下午2:35:57
 */
@Service("friendService")
public class FriengServiceImpl implements FriendService {

	@Autowired
	private FriendMapper friendMapper = null;
	@Autowired
	private UserMapper userMapper = null;

	@Override
	public List<User> getFriendList(String userId) throws Exception {
		FriendExample example = new FriendExample();
		FriendExample.Criteria criteria = example.createCriteria();
		criteria.andUserIdEqualTo(userId);
		List<Friend> friendList = friendMapper.selectByExample(example);
		List<User> userList = new ArrayList<User>();
		for (Friend friend : friendList) {
			userList.add(userMapper.selectByPrimaryKey(friend.getFriendId()));
		}
		return userList;
	}

}
